layui.use(['LDLayout', 'laydate', 'form'], function () {
    var LDLayout = layui.LDLayout,
        laydate = layui.laydate,
        form = layui.form,
        layer = layui.layer;
    laydate.render({
            elem: '#date_hook',
            theme: '#620060',
            done: function (value, date, endDate) {

            }
        })
    // 设置中间内容区 最小高度
    LDLayout.setMinHeight();
    $(window).on('resize', LDLayout.setMinHeight);

    // 新增收货地址
    $('#add_address_hook').on('click', function () {
        openAddressLayer('新增收货地址');
    })

    // 选择收货地址
    $('.address-item').on('click', function () {
        $(this).addClass('active').siblings().removeClass('active')
    })
});

function openAddressLayer (title) {
    layer.open({
        type: 1,
        skin: 'ld-layer',
        title: title,
        area: ['760px', '450px'],
        success: function () {
            $('#city_picker_hook').citypicker();
        },
        content: '<form class="layui-form layer-form address-layer" action="#">\n' +
        '            <div class="form-row">\n' +
        '                <label for="">\n' +
        '                    <span>收货人</span>\n' +
        '                    <span>:</span>\n' +
        '                </label>\n' +
        '                <div class="row-value">' +
        '                   <input type="text" placeholder="请填写收货人">\n' +
        '                </div>' +
        '            </div>\n' +
        '            <div class="form-row">\n' +
        '                <label for="">\n' +
        '                    <span>联系电话</span>\n' +
        '                    <span>:</span>\n' +
        '                </label>\n' +
        '               <div class="row-value">' +
        '                  <input type="text" placeholder="请填写联系电话">\n' +
        '               </div>' +
        '            </div>\n' +
        '            <div class="form-row">\n' +
        '                <label for="">\n' +
        '                    <span>所在地区</span>\n' +
        '                    <span>:</span>\n' +
        '                </label>\n' +
        '               <div class="row-value">' +
        '                <input type="text" id="city_picker_hook" placeholder="请选择所在地区" readonly data-toggle="city-picker">\n' +
        '               </div>' +
        '            </div>\n' +
        '            <div class="form-row">\n' +
        '                <label for="">\n' +
        '                    <span>详细地址</span>\n' +
        '                    <span>:</span>\n' +
        '                </label>\n' +
        '               <div class="row-value">' +
        '                <input type="text" placeholder="请填写详细地址" />\n' +
        '               </div>' +
        '            </div>\n' +
        '        </form>', //这里content是一个普通的String
        btn: ['确认', '取消']
    });
}